<template>
  <view class="container">
    <!-- 列表 -->
    <scroll-view
      scroll-y
      :scroll-top="scrollTop"
      :scroll-with-animation="true"
      refresher-enabled
      :refresher-triggered="refreshStatus"
      :enable-back-to-top="true"
      @refresherrefresh="resetRefresh(true)"
      @scrolltolower="reachBottom"
    >
      <view class="record-list">
        <OrderItem v-for="record in dataSource" :operatable="false" :record="record" :key="record.id" />
        <!-- 加载结束列表为空时展示 -->
        <ve-empty v-if="dataSource.length == 0 && loadStatus == 'nomore'"></ve-empty>
        <!-- 底部加载状态 -->
        <ve-load-more v-else :status="loadStatus" bgColor="#F7F7F9"></ve-load-more>
      </view>
    </scroll-view>
  </view>
</template>

<script setup>
  import { onLoad } from '@dcloudio/uni-app'
  import { ref } from 'vue'
  import useList from '@/hooks/useList'
  import OrderItem from './components/orderItem.vue'

  const props = defineProps({
    orderId: String,
  })

  const queryParam = ref({})
  const { resetRefresh, reachBottom, loadData, scrollTop, loadStatus, refreshStatus, dataSource } = useList(
    '/V5/carMaintenance/getList',
    queryParam,
  )

  onLoad((data) => {
    queryParam.value = {
      carId: props.orderId,
      feeStatus: undefined, // 全部
      pageNumber: 1,
    }
    loadData()
  })
</script>

<style lang="scss" scoped>
  page {
    background-color: rgba(247, 248, 250, 1);
    padding-bottom: 132rpx;
  }
  .container {
    height: 100vh;
    background-color: rgba(247, 248, 250, 1);
  }
  .record-list {
    padding: 24rpx 24rpx;
  }
  .ve-bottom-box {
    height: auto;
  }
</style>
